import tensorflow as tf
import os
import sys

model_path = '../../../../../../large_data/model/inceptionV3/tensorflow_inception_graph.pb'
VER = 'v3.0'
FILE_NAME = os.path.basename(__file__)
LOG_DIR = os.path.join('_log', FILE_NAME, VER)

if os.path.exists(LOG_DIR) and len(os.listdir(LOG_DIR)) > 0:
    print('Log file is already generated. Please change the VER to generate a new log.')
    sys.exit(0)

with open(model_path, 'rb') as f:
    bin = f.read()

graphDef = tf.GraphDef()
graphDef.ParseFromString(bin)
tf.import_graph_def(graphDef)

with tf.Session() as sess:
    with tf.summary.FileWriter(LOG_DIR) as fw:
        fw.add_graph(sess.graph)
        print('Graph is written to log. Please check it with tensorboard.')
